Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make corrections #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

make corrections #122

wants to merge 1 commit into from

Conversation

kirawi
Copy link

@kirawi kirawi commented Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR corrects the handling of input types and parameter types to align with mupdf expectations for document opening and page rendering.

  • Updated Document::open to accept any type implementing AsRef with appropriate OS-specific conversions.
  • Changed Page::to_pixmap to accept a bool for the alpha parameter instead of a f32.
  • Adjusted the test in tests/test_issues.rs to pass a boolean value for the alpha parameter.

Reviewed Changes

File Description
src/document.rs Updated the open method for generic path handling.
src/page.rs Changed the alpha parameter from f32 to bool in to_pixmap.
tests/test_issues.rs Modified the test to pass a boolean for alpha.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.


#[cfg(not(windows))]
let raw = p.as_ref().as_os_str().as_encoded_bytes();
let c_name = CString::new(raw)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure about this code. I understand the idea, however we are setting the users up with the expectation that every path is accepted here, which then is not the case on windows.

Maybe creating a newtype that is From<&str> for X and AsRef<X> for &str while creatable from a Path if the path is utf-8 on windows. This would allow us to skip with check entirely if a &str is used, as we already know it's utf-8. It would also make it a bit clearer that this is a failure that could occur. I'm only throwing ideas out so maybe that's a bit overkill. Else this looks good.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can create a newtype.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants